<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        table {
            border: 1px solid #000;
            text-align: center;
            width: 100%;
        }
        
        td {
            border: 1px solid #000;
        }
        
        h4 {
            text-align: center;
            /* 将span转换为块级元素 */
        }
    </style>
</head>

<body>
    <div id="app">
        <h4>欢迎光临_vue开发的收银系统_水果店</h4>
        <table>
            <tr>
                <td>苹果{{price}}￥/斤,折扣
                    <8折>
                </td>
            </tr>
            <tr>
                <td>
                    请输入你要购买的斤数 <input type="number" v-model="weight">
                </td>
            </tr>
            <tr>
                <td>
                    <button @click="pay">结账买单~</button>
                </td>
            </tr>
            <tr>
                <td>
                    结账单:总价:{{total}}￥元 折价后:{{total * 0.8}}￥元 省了:{{total * 0.2}}￥元
                </td>
            </tr>


        </table>
    </div>

    <script src="../vue.js"></script>

    <script>
        const app = new Vue({
            el: '#app',
            data: {
                weight: '',
                price: 10,
                total: 0
            },
            methods: {
                pay() {
                    // 总价
                    this.total = this.price * this.weight
                        // 折扣
                        // discount = this.total * 0.8
                        //     // 省了
                        // spare = this.total - this.discount
                }
            }
        })
    </script>
</body>

</html>